<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- <style>
         td{
             border: 1px solid rebeccapurple;
             width: 150px;
             text-align: center;
         }
     </style>-->
</head>
<body>
<table>
    <thead>
    <tr>
        <td><input type="checkbox" id="check"> </td>

    </tr>
    </thead>
    <tbody id="tbody">
    <tr>
        <td><input type="checkbox" name="user"></td>

    </tr>
    <tr>
        <td><input type="checkbox" name="user"></td>

    </tr>
    <tr>
        <td><input type="checkbox" name="user"></td>

    </tr>
    <tr>
        <td><input type="checkbox" name="user"></td>

    </tr>


    </tbody>
</table>
</body>
<script>
    document.getElementById("check").onclick = function(){
        var checked = document.getElementById("check").checked;
        var checkson = document.getElementsByName("user");
        if(checked){
            for(var i = 0; i < checkson.length ;i++){
                checkson[i].checked = true;
            }
        }else{
            for(var i = 0; i < checkson.length ;i++){
                checkson[i].checked = false;
            }
        }
    }
</script>
</html>
